<!--
 * @Descripttion: 认购单
 * @version: 
 * @Author: mmzhang
 * @Date: 2021-07-20 10:57:26
 * 注意因为transform 对position fixed属性的影响 这里要禁用tab切换的动画
 * @LastEditTime: 2023-02-06 17:14:53
-->
<template>
  <div class="subscription-form">
    <div>
      <Tabs type="card" v-model="showTab" :animated="false">
        <TabPane label="认购单列表" name="subList">
          <subscription-list v-model='fetchInfo' ref="subscriptionList" v-if="showTab=='subList' && unlocking('0104010100')"></subscription-list>
        </TabPane>
        <TabPane label="认购单附件" name="enclosureList">
          <enclosure-list v-model='fetchInfo' ref="enclosureList" v-if="showTab=='enclosureList' && unlocking('0104010200')"></enclosure-list>
        </TabPane>
      </Tabs>
    </div>
  </div>
</template>
<script>
import subscriptionList from './components/subscriptionList.vue'
import enclosureList from './components/enclosureList.vue'
import dt from '@dt/dt'
export default {
  components: { subscriptionList, enclosureList },
  data() {
    return {
      showTab: 'subList',
      fetchInfo: {}
    }
  },
  beforeRouteEnter(to, from, next) {
    if (from.name != 'subscriptionDetail' && from.name != 'statistics')
      dt.memory.remove('subOrder_params')
    next()
  },
  beforeRouteLeave(to, from, next) {
    if (to.name === 'subscriptionDetail') {
      if (this.showTab == 'subList') {
        this.$refs.subscriptionList.retainParamsFun()
      } else {
        this.$refs.enclosureList.retainParamsFun()
      }
    } else {
      dt.memory.remove('subOrder_params')
      if (this.showTab == 'subList') {
        this.$refs.subscriptionList.resetNumFun()
      }
    }
    next()
  },
  created() {
    this.showTab =
      dt.memory.get('subOrder_params') &&
      dt.memory.get('subOrder_params').showTab
        ? dt.memory.get('subOrder_params').showTab
        : 'subList'
  },
  watch: {
    showTab(val, oldVal) {
      dt.memory.remove('subOrder_params')
    },
  },
  mounted() {},
  methods: {},
}
</script>
<style lang="scss" scoped>
.subscription-form {
  padding: 20px;
}
</style>